package com.tsc.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tsc.stock.mapper.StockMapper;
import com.tsc.stock.pojo.Stock;
import com.tsc.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/08/28/09:44
 * @Description:
 */
@Service
public class StockServiceImpl implements StockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public String reduct(Integer productId) {
        stockMapper.update(new UpdateWrapper<Stock>()
                .setSql("count = count-1")
                .eq("product_id", productId));
        return "库存删减成功";
    }
}
